<!--
* @FileDescription: 医生表格
* @Date: 2022年11月21日 16:29:49
* TODO:
* [] Demo
-->

<template>
	<div>
		<el-table :data="doctorData.data">
			<!-- <el-table-column type="selection" width="55" align="center" /> -->
			<el-table-column type="index" label="序号" />
			<el-table-column prop="customerId" label="患者编号"> </el-table-column>
			<el-table-column prop="customerName" label="患者姓名"> </el-table-column>
			<el-table-column prop="counterName" label="诊室名称"> </el-table-column>
			<el-table-column prop="reportTime" label="报到时间"> </el-table-column>
			<el-table-column prop="callTime" label="就诊时间"> </el-table-column>
			<el-table-column prop="waitTime" label="等候时长">
				<template slot-scope="scope">
					{{ hanldeTime(scope.row.waitTime) }}
				</template>
			</el-table-column>
			<el-table-column prop="staffName" label="医生姓名"> </el-table-column>
			<el-table-column prop="overTime" label="过号时间"> </el-table-column>
		</el-table>

		<!--  v-show="queueStatList.total > 0"-->
		<pagination
			:total="doctorData.total"
			:page.sync="query.current"
			:limit.sync="query.size"
			@pagination="pageChange"
		/>
	</div>
</template>

<script>
import { staffCounterDetail, getStaffAllData } from '@/api/qbs/queueStat'
export default {
	name: 'doctorTable',
	components: {},
	// filters:{},
	// mixins:[],
	props: {
		staffId: { type: String, default: '' },
		counterId: { type: String, default: '' },
		queryParams: { type: Object, default: {} },
	},
	data() {
		return {
			doctorData: {},
			query: { current: 1, size: 10 },
		}
	},
	// computed:{},
	watch: {
		async staffId(val) {
			console.log(`staffId`, { val: val })
			await staffCounterDetail()
		},
		async counterId(val) {
			console.log(`counterId`, { val: val })
			await staffCounterDetail()
		},
	},
	mounted() {
		this.query.beginTime = this.queryParams.beginTime
		this.query.endTime = this.queryParams.endTime
		this.getDetailList()
	},
	methods: {
		hanldeTime(data) {
			if (data) {
				let second = data % 60
				let minute = Math.floor(data / 60) % 60
				let hour = Math.floor(data / 3600)
				return `${hour}小时${minute}分钟${second}秒`
			}else{
        return ''
      }
		},
		pageChange(size) {
			this.query.current = size.page
			this.query.size = size.limit
			// this.$emit('pageChange', this.queryParams)
			this.getDetailList()
		},
		// 获取医生详细数据
		async getDetailList() {
			if (this.counterId) {
				this.doctorData = await staffCounterDetail({
					staffId: this.staffId,
					counterId: this.counterId,
					...this.query,
				})
				this.$forceUpdate()
			} else {
				this.doctorData = await getStaffAllData({
					staffId: this.staffId,
					...this.query,
				})
				this.$forceUpdate()
			}
		},
		handlerTime(time) {
			let minus = Math.floor(time / 60) % 601
			let second = time % 60
			let hours = Math.floor(time / 3600) % 60
			return `${hours}时${minus}分${second}秒`
		},
	},
}
</script>
<style lang="scss" scoped></style>
